#ifndef _W25Q_H
#define _W25Q_H

#include "stm32f4xx.h"
#include "spi.h"

#define W25Q_CS_0  HAL_GPIO_WritePin(F_CS_GPIO_Port, F_CS_Pin , GPIO_PIN_RESET)
#define W25Q_CS_1  HAL_GPIO_WritePin(F_CS_GPIO_Port, F_CS_Pin , GPIO_PIN_SET)


#define W25Q_WRITE_ENABLE    0x06
#define W25Q_WRITE_DISABLE   0x04

#define W25Q_PageProgram     0x02
#define W25Q_ReadPage 			 0x03

#define W25Q_ReadStatusReg1  0x05
#define W25Q_ReadStatusReg2  0x35
#define W25Q_ReadStatusReg3  0x15
#define W25Q_ManufactDevID   0x90

#define W25Q_ChipErase       0xC7


void W25Q_Init(void);


void W25Q_Write_Enable();
void W25Q_Write_Disable();
void W25Q_Chip_Erase();
void W25Q_Write_Page(uint32_t pageAddr,uint8_t* pBuf,uint16_t bytes);
void W25Q_Read_Page(uint32_t pageAddr,uint8_t* pBuf,uint16_t bytes);

void W25Q_WriteBytes(uint8_t *data, uint8_t num);
void W25Q_ReadBytes(uint8_t *data, uint8_t num);
uint8_t W25Q_ReadWrite(uint8_t tx_data);
uint16_t W25Q_ReadDevId(void);



uint8_t Read_Status_Register(uint8_t cmd);
#endif